home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / refres / refresh.frm < prev    next >
Text File  |  1995-05-08  |  7KB  |  195 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00808000&
  5.    Caption         =   "REFRESH DEMO"
  6.    ClientHeight    =   4125
  7.    ClientLeft      =   960
  8.    ClientTop       =   1770
  9.    ClientWidth     =   5010
  10.    ForeColor       =   &H00000000&
  11.    Height          =   4815
  12.    Icon            =   REFRESH.FRX:0000
  13.    Left            =   900
  14.    LinkMode        =   1  'Source
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    ScaleHeight     =   4125
  18.    ScaleWidth      =   5010
  19.    Top             =   1140
  20.    Width           =   5130
  21.    Begin TextBox txbRefreshed 
  22.       BackColor       =   &H0000C000&
  23.       ForeColor       =   &H00000000&
  24.       Height          =   615
  25.       Left            =   240
  26.       TabIndex        =   3
  27.       TabStop         =   0   'False
  28.       Top             =   3120
  29.       Width           =   4500
  30.    End
  31.    Begin TextBox txbRefComment 
  32.       BackColor       =   &H00808000&
  33.       FontBold        =   -1  'True
  34.       FontItalic      =   -1  'True
  35.       FontName        =   "MS Sans Serif"
  36.       FontSize        =   8.25
  37.       FontStrikethru  =   0   'False
  38.       FontUnderline   =   0   'False
  39.       ForeColor       =   &H00000000&
  40.       Height          =   285
  41.       Left            =   2520
  42.       TabIndex        =   7
  43.       TabStop         =   0   'False
  44.       Top             =   2760
  45.       Width           =   2175
  46.    End
  47.    Begin TextBox txbNonRefreshed 
  48.       BackColor       =   &H000000FF&
  49.       ForeColor       =   &H00000000&
  50.       Height          =   615
  51.       Left            =   240
  52.       TabIndex        =   2
  53.       TabStop         =   0   'False
  54.       Top             =   1800
  55.       Width           =   4500
  56.    End
  57.    Begin TextBox txbNonRefComment 
  58.       BackColor       =   &H00808000&
  59.       FontBold        =   -1  'True
  60.       FontItalic      =   -1  'True
  61.       FontName        =   "MS Sans Serif"
  62.       FontSize        =   8.25
  63.       FontStrikethru  =   0   'False
  64.       FontUnderline   =   0   'False
  65.       ForeColor       =   &H00000000&
  66.       Height          =   285
  67.       Left            =   2520
  68.       TabIndex        =   8
  69.       TabStop         =   0   'False
  70.       Top             =   1440
  71.       Width           =   2175
  72.    End
  73.    Begin TextBox txbWidthValue 
  74.       BackColor       =   &H00808000&
  75.       BorderStyle     =   0  'None
  76.       FontBold        =   -1  'True
  77.       FontItalic      =   0   'False
  78.       FontName        =   "MS Sans Serif"
  79.       FontSize        =   12
  80.       FontStrikethru  =   0   'False
  81.       FontUnderline   =   0   'False
  82.       ForeColor       =   &H00000040&
  83.       Height          =   375
  84.       Left            =   3840
  85.       TabIndex        =   0
  86.       TabStop         =   0   'False
  87.       Text            =   "4500"
  88.       Top             =   360
  89.       Width           =   735
  90.    End
  91.    Begin CommandButton cmbDemo 
  92.       BackColor       =   &H0000FFFF&
  93.       Caption         =   "START DEMO"
  94.       Height          =   615
  95.       Left            =   240
  96.       TabIndex        =   1
  97.       Top             =   240
  98.       Width           =   1695
  99.    End
  100.    Begin Label Label2 
  101.       BackColor       =   &H00808000&
  102.       Caption         =   "Changing Width Value Using Explicit Refresh."
  103.       Height          =   375
  104.       Left            =   240
  105.       TabIndex        =   5
  106.       Top             =   2640
  107.       Width           =   2175
  108.    End
  109.    Begin Label Label1 
  110.       BackColor       =   &H00808000&
  111.       Caption         =   "Changing Width Value With VB's Idle Refresh."
  112.       Height          =   375
  113.       Left            =   240
  114.       TabIndex        =   4
  115.       Top             =   1320
  116.       Width           =   2175
  117.    End
  118.    Begin Label Label3 
  119.       BackColor       =   &H00808000&
  120.       Caption         =   "Width ="
  121.       FontBold        =   -1  'True
  122.       FontItalic      =   0   'False
  123.       FontName        =   "MS Sans Serif"
  124.       FontSize        =   12
  125.       FontStrikethru  =   0   'False
  126.       FontUnderline   =   0   'False
  127.       Height          =   375
  128.       Left            =   2880
  129.       TabIndex        =   6
  130.       Top             =   360
  131.       Width           =   975
  132.    End
  133.    Begin Menu mnuHelp 
  134.       Caption         =   "&Help"
  135.       Begin Menu mnuNotes 
  136.          Caption         =   "&Notes..."
  137.       End
  138.       Begin Menu mnuAbout 
  139.          Caption         =   "&About..."
  140.       End
  141.    End
  142. End
  143. Const ttlHelpAbout$ = "Who Done It?"
  144. Const msgHelpAbout$ = "Just for fun - Peter Hartquist 73227,3600"
  145. Const ttlHelpNotes$ = "What Does It Do?"
  146. Const msgHelpNotes$ = "According the the Language Reference manual, refreshing a form or control happens automatically when VB's idle loop is reached.  This demo shows the effect of explicitly using Refresh on a dynamically changing control."
  147.  
  148. '
  149. '   According the the Visual Basic Language Reference manual, refreshing
  150. '   a form or control happens automatically when VB's idle loop is reached.
  151. '   In this example I have created a situation to demonstrate
  152. '   the effects of using or not using Refesh on a control
  153. '   (a text box) while it repetitively changes in width.
  154. '
  155. '   I have created two similar controls on the form.  One text box changes
  156. '   without using Refresh and one changes with Refresh on each change.
  157. '
  158. '   It looks like Refresh is not necessary when decreasing the width of a
  159. '   text box control.  It actually causes jitter in the redrawn image.
  160. '   But Refresh is needed to see the effects of repetitively increasing
  161. '   the width of the text box.  Without Refresh, the text box doesn't
  162. '   display with its' correct width until the repetitive changes have
  163. '   all been completed.
  164. '
  165. '
  166. Sub cmbDemo_Click ()
  167.     cmbDemo.Enabled = False
  168.     txbNonRefComment.Text = "Smooth"  'Comments while
  169.     txbRefComment.Text = "Jitters a bit"    'Width decreases
  170.     For I = -4500 To 4500 Step 50     'Initial Textbox Width = 4500
  171.     If Abs(I) < 250 Then              'Handle low wdith value
  172.     I = 250                           'Avoid low or zero I value
  173.     txbNonRefComment.Text = "Wrong Width" 'Comments while
  174.     txbRefComment.Text = "Correct Width"  'Width increases
  175.     End If                            '
  176.     txbWidthValue.Text = Str$(Abs(I)) 'Display Width Value
  177.     txbNonRefreshed.width = Abs(I)    'Change Textbox 1 without Refresh
  178.     txbRefreshed.width = Abs(I)       'Change Testbox 2
  179.     txbRefreshed.Refresh              'With Refresh
  180.     Next I                            'Loop till done
  181.     txbNonRefComment.Text = "Correct Width At Last" 'Comments
  182.     txbRefComment.Text = "Correct Width"            'when done
  183.     cmbDemo.Enabled = True
  184.     cmbDemo.Caption = "SEE IT AGAIN ?"
  185. End Sub
  186.  
  187. Sub mnuAbout_Click ()
  188.     MsgBox msgHelpAbout$, 64, ttlHelpAbout$
  189. End Sub
  190.  
  191. Sub mnuNotes_Click ()
  192.     MsgBox msgHelpNotes$, 64, ttlHelpNotes$
  193. End Sub
  194.  
  195.